<template>
  <div class="countersign-configuration">
    <je-form-item :label="$t('CountersignConfiguration.ruleType')" name="counterSignPassType">
      <je-select
        v-model:value="formState.counterSignPassType"
        config-info="JE_WF_COUNTERSIGNTYPE,counterSignPassType,code,S"
      />
    </je-form-item>
    <je-form-item
      v-if="formState.counterSignPassType == 'PASS_PERSENT'"
      :label="$t('CountersignConfiguration.passScale')"
      name="amount"
    >
      <je-select v-model:value="formState.amount" config-info="JE_PERCENTAGE,amount,code,S" />
    </je-form-item>
    <je-form-item
      v-if="formState.counterSignPassType == 'PASS_PRINCIPAL'"
      :label="$t('CountersignConfiguration.principal')"
      name="PASS_PRINCIPAL"
    >
      <je-select-user
        v-model:model="formState"
        v-model:value="formState.oneBallotUserName"
        config-info=",oneBallotUserName~oneBallotUserId,text~id,S"
      />
    </je-form-item>
    <je-form-item :label="$t('CountersignConfiguration.allVoting')" name="voteAll">
      <je-switch v-model:value="formState.voteAll" mode="checkbox" />
      <span class="prompt">{{ $t('CountersignConfiguration.allVotingContext') }}</span>
    </je-form-item>
    <je-form-item :label="$t('CountersignConfiguration.orderApproval')" name="sequential">
      <je-switch v-model:value="formState.sequential" mode="checkbox" />
      <span class="prompt">{{ $t('CountersignConfiguration.orderApprovalContext') }}</span>
    </je-form-item>
    <je-form-item :label="$t('CountersignConfiguration.RuntimeAdjustment')" name="runtimeTuning">
      <je-switch v-model:value="formState.runtimeTuning" mode="checkbox" />
      <span class="prompt">{{ $t('CountersignConfiguration.RuntimeAdjustmentContext') }}</span>
    </je-form-item>
    <je-form-item
      :label="$t('CountersignConfiguration.PreoperationAdjustment')"
      name="adjustBeforeRunning"
    >
      <je-switch v-model:value="formState.adjustBeforeRunning" mode="checkbox" />
      <span class="prompt">{{ $t('CountersignConfiguration.PreoperationAdjustmentContext') }}</span>
    </je-form-item>
    <je-form-item :label="$t('CountersignConfiguration.deselectAll')" name="deselectAll">
      <je-switch v-model:value="formState.deselectAll" mode="checkbox" />
      <span class="prompt">{{ $t('CountersignConfiguration.deselectAllContext') }}</span>
    </je-form-item>
    <div class="info">
      <span class="p">
        {{ $t('CountersignConfiguration.context') }}
      </span>
    </div>
  </div>
</template>

<script>
  import { defineComponent, ref, watch } from 'vue';
  import { Form, Select, InputSelect, Switch } from '@jecloud/ui';

  export default defineComponent({
    name: 'CountersignConfiguration',
    components: {
      JeFormItem: Form.Item,
      JeSelect: Select,
      JeSelectUser: InputSelect.User,
      JeSwitch: Switch,
    },
    props: {
      taskCounterSignConfig: {
        type: Object,
        default: () => {
          return {};
        },
      },
      nodeId: {
        type: String,
        default: '',
      },
    },
    setup(props) {
      //表单数据
      const formState = ref(props.taskCounterSignConfig);

      watch(
        () => props.nodeId,
        () => {
          formState.value = props.taskCounterSignConfig;
        },
      );

      return { formState };
    },
  });
</script>
